<template>
  <PageLayout :navbarShow="false">
    <view class="wrap">
      <wd-navbar
        title="会员名片"
        left-text="返回"
        left-arrow
        @click-left="handleClickLeft"
        safeAreaInsetTop
      ></wd-navbar>
      <view class="member-box">
        <view class="member-avatar" @click="goPersonDetail(item)">
          <wd-img
            v-if="showData.avatar"
            width="100"
            height="100"
            :round="true"
            :src="showData.avatar"
          ></wd-img>
          <view v-else class="default-avatar">未设置头像</view>
        </view>
        <view class="member-info">
          <view>{{ showData.realname }}</view>
          <view>{{ `[籍贯]${showData.province}/${showData.city}/${showData.district}` }}</view>
          <view>{{ `[星球身份]${showData.companyName}` }}</view>
          <view>{{ `[公司职位]${showData.companyPosition}` }}</view>
        </view>
      </view>
      <view class="person-info-box">
        <view>个人简介</view>
        <view>{{ showData.realname }}</view>
        <view>{{ `[兴趣爱好]${showData.interests}` }}</view>
        <view>{{ `[籍贯]${showData.province}/${showData.city}/${showData.district}` }}</view>
        <view>{{ `[星球身份]${showData.companyName}` }}</view>
        <view>{{ `[从事行业]${showData.industryCategory}` }}</view>
        <view>{{ `[公司职位]${showData.companyPosition}` }}</view>
        <view>{{ `[公司地址]${showData.companyAddress}` }}</view>
      </view>
    </view>
    <view class="share" @click="share">分享给好友</view>
  </PageLayout>
</template>

<script setup>
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { http } from '@/utils/http'
const routeParams = ref({})
const showData = ref({})
onLoad((options) => {
  routeParams.value = options
  initData()
})
const initData = () => {
  console.log('路由参数:', routeParams.value.id)
  http
    .get('/chamber/ccUser/queryById', {
      id: routeParams.value.id,
    })
    .then((res) => {
      if (res.success) {
        console.log(res)
        showData.value = res.result
      }
    })
}
const handleClickLeft = () => {
  uni.navigateBack()
}
const share = () => {
  uni.downloadFile({
    url: 'https://res.wx.qq.com/wxdoc/dist/assets/img/demo.ef5c5bef.jpg',
    success: (res) => {
      wx.showShareImageMenu({
        path: res.tempFilePath,
      })
    },
  })
}
</script>

<style lang="scss" scoped>
:deep(.wd-navbar) {
  background: linear-gradient(45deg, #0081ff, #1cbbb4);
  height: 50px;
}
.member-box {
  display: flex;
  background-color: white;
  margin-bottom: 20px;
  padding: 15px;
  border-radius: 8px;

  .member-avatar {
    width: 100px;
    height: 100px;
    margin-right: 15px;
  }

  .member-info {
    flex: 1;
    > view {
      margin-bottom: 5px;
      &:last-child {
        margin-bottom: 0;
      }
    }
  }
}
.share {
  margin-top: 10px;
  text-align: center;
  background-color: white;
  padding: 10px 0;
}
</style>
